<?php
session_start();
mb_internal_encoding("UTF-8");
if(!defined('PATH_ROOT')) die("No path root defined !!!");

    
// find controller and function
if (!empty($_REQUEST['con'])) {
    extract($_REQUEST);
    if(empty($fun)) $fun='lista';

    $con = camelize($con)."Ctrl";
 
    //echo "klasa: ".$con;
    try {
	$mt=get_class_methods($con);
        if (empty($mt) || (!in_array($fun,$mt) && !in_array('__call',$mt))){
            $s->assign('content', $s->fetch('noBodyFile.tpl'));
        } else {
			$controller = new $con();
			die($controller->$fun());
		}
    } catch (Exception $e) {
        var_dump($e);
        $s->assign('content', $s->fetch('noBodyFile.tpl'));
        //echo $e->getMessage();
    }
}else{
	//header("Location: index.php?con=teksty&fun=strona_glowna"));
	header("Location: index.php?con=start&fun=test");
	//die("nie podano CTRL");
}
die("nie zrobiono nic konkretnego");
//$s->display('index.tpl');

